﻿import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
Rectangle{
    id: root
    //    title: "维护校正"
    width: parent.width
    height:  parent.height
    color: "white"
    radius: 12
    property var gzdata: CMaintenance.getFaultInformation("2")
    onVisibleChanged: {
        gzdata=CMaintenance.getFaultInformation("2")
    }
    Connections{
        target: CExeConfig
        onMaskingInformation:{
            gzdata=CMaintenance.getFaultInformation("2")
        }
    }

    CustomPopupBoxWarning{
        id: gzadd
        box_text: "故障信息不允许删除，请确认是否添加！"
        onAccepted: {
            CMaintenance.addFaultInformation()
            gzdata=CMaintenance.getFaultInformation()
        }
    }
    // 故障
    Rectangle{
        id: layout_failure
        x:parent.width*0.1
        y:40*dp
        width: parent.width*0.8
        height: parent.height*0.75
        visible: true
        color: "white"
        CustomButton{
            title: "新建"
            y:20*dp
            x:parent.width/2+300*dp
            defaultMode1: true
            onReleased: {
                gzadd.show()
            }
        }

        Rectangle{
            x:0*dp
            y:85*dp
            height: 2*dp
            width: defmod2.width
            color: "#DEDEDE"
        }

        Row{
            y: 90*dp
            width: parent.width; height: 38*dp
            Text {
                width:parent.width*0.1
                horizontalAlignment: Text.AlignHCenter
                text: qsTr("序号")
                color: "#666666"
                font.pixelSize: config.fontsize
            }
            Text {
                width:parent.width*0.1
                horizontalAlignment: Text.AlignHCenter
                text: qsTr("模块")
                color: "#666666"
                font.pixelSize: config.fontsize
            }
            Text {
                width:parent.width*0.1
                horizontalAlignment: Text.AlignHCenter
                text: qsTr("故障代码")
                color: "#666666"
                font.pixelSize: config.fontsize
            }
            Text {
                width:parent.width*0.4
                horizontalAlignment: Text.AlignHCenter
                text: qsTr("故障信息")
                color: "#666666"
                font.pixelSize: config.fontsize
            }
            Text {
                width:parent.width*0.15
                horizontalAlignment: Text.AlignHCenter
                text: qsTr("处理方案(是否继续)")
                color: "#666666"
                font.pixelSize: config.fontsize
            }
            Text {
                width:parent.width*0.15
                horizontalAlignment: Text.AlignHCenter
                text: qsTr("是否屏蔽")
                color: "#666666"
                font.pixelSize: config.fontsize
            }
        }
        Rectangle{
            x:0*dp
            y:129*dp
            height: 2*dp
            width: parent.width
            color: "#DEDEDE"
        }
        ScrollView {
            x:0*dp
            y:132*dp
            width: parent.width
            height: parent.height-40*dp
            clip: true
            Column{
                id: myColumnLayout2
                width: layout_failure.width
//                height: layout_failure.height
                spacing: 1*dp
                Repeater{
                    id:defmod2
                    model: gzdata
                    delegate: Item {
                        x:0*dp
                        width: layout_failure.width
                        height: 60*dp
                        DefTab2COM{
                            width: parent.width
                            height: parent.height
                            xh:modelData.serial
                            mk:modelData.module
                            gzdm:modelData.errorCode
                            gzxx:modelData.errorName
                            isjxv:modelData.errorMethod==="是"
                            ispbv:modelData.isBlocked==="是"
                            onRefre: {
                                gzdata=CMaintenance.getFaultInformation()
                            }
                        }
                    }
                }
            }
        }

    }

}
